Image Commands
|
Main features of image-related
commands are:
-
replacing images in
bitmap and hotspot objects
-
viewing images in a
separate window
-
resizing, rotating,
zooming of images
For examples of usage the below commands can be found
in test_image.mbd,
ImageDemo.mbd
or clock_3.mbd
|
ViewImage("Path","Parameters")
|
|
|
|
Displays
external
JPEG
or
BMP
image
in
a
separate
window.
First
parameter
sets
file
to
load
and
requires
either
a)
folder
path
+
video
file
name,
or
b)
path
macro
+
video
file
name
Second
parameter
is
optional
and
can
be
used
to
center
image
window
on
the
screen:
CENTER
|
|
|
|
|
**View
JPEG
file
NewImage.jpg
placed
in
folder
c:\My
Project
ViewImage("c:\My
Project\NewImage.jpg","")
**View
BMP
file
HotImage.bmp
placed
in
<SrcDir>
folder
**having
window
centered
on
screen
ViewImage("<SrcDir>\HotImage.bmp","CENTER")
|
|
|
|
|
Position
of
image
window
is
saved
and
will
be
used
on
the
next
window
opening
if
second
parameter
(CENTER)
is
not
set.
|
|
|
ReplaceImage("ObjectLabel","Path")
|
|
|
|
Replaces
current
image
of
specified
Bitmap,
HotSpot
or
Polygonal
HotSpot
object
with
an
external
JPEG
or
BMP
file.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
MainImage
Second
parameter
sets
file
to
load
and
requires
either
a)
folder
path
+
video
file
name,
or
b)
path
macro
+
video
file
name
|
|
|
|
|
**Replace
image
in
bitmap
object
labeled
MainImage
with
JPEG
file
**NewImage.jpg
placed
in
folder
c:\My
Project
ReplaceImage("MainImage","c:\My
Project\NewImage.jpg")
**Set
image
in
hotspot
object
labeled
ColdSpot
from
BMP
file
**HotImage.bmp
placed
in
<SrcDir>
folder
ReplaceImage("ColdSpot","<SrcDir>\HotImage.bmp")
|
|
|
|
|
Using
this
command
without
second
parameter
will
clear
image
in
the
specified
object:
ReplaceImage("FacePicture","")
Previously (in 4.9 or older) ReplaceImage used on HotSpot resize the HotSpot object to Image
dimensions. But ReplaceImage in 4.9.5 keep the HotSpot width/height unchaged
and the Image is fit to the HotSpot window dimensions. If you want to change hotspot
window to the image dimensions, use RestoreImage("HotSpot") right
after ReplaceImage
command.
|
|
|
UseImageBkgColor("ObjectLabel","Parameters")
|
|
|
|
Sets
status
of
background
color
under
Bitmap
object.
If
used,
Bitmap
object
is
filled
with
background
color
before
displaying
image.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
MyImage
Second
command
parameter
enables
or
disables
image
back
color:
- 1
:
sets
image
background
color
on
- 0
:
sets
image
background
color
off
|
|
|
|
|
**Set
image
background
color
on
for
Bitmap
object
"MyImage":
UseImageBkgColor(
"MyImage","1")
**Set
image
background
color
off
for
Bitmap
object
"MyImage":
UseImageBkgColor(
"MyImage","0")
|
|
|
|
|
Use
SetImgBkgColor
command
to
set
image
background
color.
|
|
|
SetImageBkgColor("ObjectLabel","R,G,B")
|
|
|
|
Sets
image
background
color.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
BigImage
Color
setting
uses
RGB
(
Red,
Green,
Blue)
system
containing
3
components.
Each
component
can
have
one
of
256
levels.
Greater
value
of
component
increases
color
intensity.
If
you
specify
value
0,
color
component
will
not
be
used.
Value
255
uses
maximum
color
intensity.
Second
parameter
for
SetImageBkgColor
is
a
comma-separated
array
of
string
values,
each
representing
one
RGB
component
(first:
red,
second:
green,
third:
blue)
in
value
range
0-255.
Example
of
second
parameter:
150,
79,
205
Put
together,
command
with
parameters
looks
like
this:
SetImageBkgColor("BigImage","
150,
79,
205")
You
can
also
use
string
variable
for
color
setting:
color$='
150,
79,
205'
SetImageBkgColor("BigImage","color$")
|
|
|
|
|
**Set
blue
background
color
for
image
labeled
"RearImage":
SetImageBkgColor("
RearImage
","0,0,255")
**Set
cyan
background
color
for
image
labeled
"RearImage"
using
**string
variable
as
a
color
source:
MyColor$='0,255,255'
SetImageBkgColor("
RearImage
","MyColor$")
|
|
|
SetImageOrigin("ObjectLabel","X,Y")
|
|
|
|
Sets
starting
point
(origin),
relative
to
the
top
left
image
corner,
that
will
be
used
for
image
resizing
and
rotation.
Both
resizing
and
rotation
will
be
performed
around
this
point.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
RotoImage
Second
command
parameter
consists
of
two
coordinates.
Horizontal
(X)
coordinate,
for
e.g.:
80
Vertical
(Y)
coordinate,
for
e.g.:
30
Coordinates
in
second
parameter
are
separated
with
commas,
so
here's
an
example
of
complete
command:
SetImageOrigin("RotoImage","80,30")
|
|
|
|
|
**Set
starting
point
for
object
"RotoImage"
to
154
(X),
84
(Y):
SetImageOrigin(
"RotoImage","154,84")
|
|
|
ResizeImage("ObjectLabel","W,H")
|
|
|
|
Resize
the Image Object
to the new size
specified using
the origin as
the transformation
center.
This
is a simple example
of resizing Image
with default origin
point:
And
the example here
shows you how to
resize image using
the image Origin
set to right-bottomcorner
of the original
image.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
AlterImage
Second
command
parameter
consists
of
two
coordinates.
Horizontal
(W)
coordinate,
for
e.g.:
80
Vertical
(H)
coordinate,
for
e.g.:
60
Coordinates
in
second
parameter
are
separated
with
commas,
so
here's
an
example
of
complete
command:
ResizeImage("Bitmap","120,90")
|
|
|
|
|
**Resize
Bitmap
object
image
"AlterImage":
ResizeImage("AlterImage","80,30")
**Set
image Origin
to Right-Bottom
corner and then
resize
image
"AlterImage"
to half size
of the original
image:
IW=ImageWidth(AlterImage) IH=ImageHeight(AlterImage) SetImageOrigin("AlterImage","IW,IH") ResizeImage("AlterImage","IW/2,IH/2")
|
|
|
RotateImageRel("ObjectLabel","Angle")
|
|
|
|
Rotates
Bitmap
object
image
relatively
from
current
angle.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
RotoImage
Second
command
parameter
sets
relative
rotation
angle
in
degrees.
Value
in
degrees
can
be
either
positive
or
negative.
For
e.g.:
80
-
rotates
image
80
degrees
clockwise
-80
-
rotates
image
80
degrees
counterclockwise
|
|
|
|
|
**Relatively
Rotate
image
in
Bitmap
object
"RotoImage"
**45
degrees
clockwise
RotateImageRel(
"RotoImage","45")
**Relatively
Rotate
image
in
Bitmap
object
"RotoImage"
**45
degrees
counterclockwise
RotateImageRel(
"RotoImage","-45")
|
|
|
RotateImageTo("ObjectLabel","Angle")
|
|
|
|
Performs
absolute
rotation
of
Bitmap
object
image
in
degrees,
starting
from
0
(default
object
angle).
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
RotoImage
Second
command
parameter
sets
absolute
rotation
angle
in
degrees.
Value
in
degrees
can
be
either
positive
or
negative.
For
e.g.:
80
-
rotates
image
80
degrees
clockwise
-80
-
rotates
image
80
degrees
counterclockwise
|
|
|
|
|
**Perform
absolute
rotation
of
image
in
Bitmap
object
"RotoImage"
**45
degrees
clockwise
RotateImageTo(
"RotoImage","45")
**Perform
absolute
rotation
of
image
in
Bitmap
object
"RotoImage"
**45
degrees
counterclockwise
RotateImageTo(
"RotoImage","-45")
|
|
|
ScrollImageView("ObjectLabel","X,Y")
|
|
|
|
Sets
displayed
part
of
Bitmap
object
image
using
coordinates
from
the
second
command
parameter.
This
can
be
used
when
image
has
a
different
width
or
height
than
Bitmap
object
canvas.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
BigImage
Second
command
parameter
sets
image
section
upper
left
coordinates.
When
image
is
smaller
than
Bitmap
object
canvas,
use
positive
coordinates
to
move
displayed
section
to
left
(x)
and
up
(y).
Positive
horizontal
(X)
coordinate,
for
e.g.:
80
Positive
vertical
(Y)
coordinate,
for
e.g.:
30
When
image
is
larger
than
Bitmap
object
canvas,
use
negative
coordinates
to
move
displayed
section
to
right
(x)
and
down
(y).
Negative
horizontal
(X)
coordinate,
for
e.g.:
-80
Negative
vertical
(Y)
coordinate,
for
e.g.:
-30
Coordinates
in
second
parameter
are
separated
with
commas,
so
here's
an
example
of
complete
command:
ScrollImageView
("BigImage","-80,-30")
|
|
|
|
|
**Display
section
of
Bitmap
object
"BigImage"
starting
with
coordinates
**-130
(X),
-80
(Y)
ScrollImageView(
"BigImage","-130,-80")
**Display
section
of
Bitmap
object
"SmallImage"
starting
with
coordinates
**30
(X),
80
(Y)
ScrollImageView(
"SmallImage","30,80")
|
|
|
|
|
To
obtain actual
X/Y position of
the left top
corner of an
image inside
the Image object
use ImageScrollX,
ImageScrollY
functions.
|
|
|
ZoomImageView("ObjectLabel","Zoom")
|
|
|
|
Zooms
in
or
out
image
of
specified
Bitmap
object.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
MapImage
Second
command
parameter
sets
zoom
percentage.
Default
image
zoom
value
is
100.
You
can
use
both
lower
and
higher
values
than
default
one.
Zooming
out
to
80%
of
image
original
size:
80
Zooming
in
to
150%
of
image
original
size:
150
|
|
|
|
|
**Zoom
out
Bitmap
object
image
"MapImage"
to
50%
of
original:
ZoomImageView(
"MapImage","50")
**Zoom
in
Bitmap
object
image
"MapImage"
to
200%
of
original:
ZoomImageView(
"MapImage","200")
|
|
|
RestoreImage("ObjectLabel")
|
|
|
|
Resets
size
and
rotation
angle
of
specified
Bitmap
object.
Use
first
parameter
to
set
Bitmap
object
label,
for
example:
AlterImage
Warning!
RestoreImage will
not work if you
remove unused graphics
from the project
with the "File>>>
Reduce Size..."
option. It simply
remove all backup
copies of the images
created within the
project creation
process.
|
|
|
|
|
**Restore
Bitmap
object
image
"AlterImage":
RestoreImage("AlterImage")
|
|
|
|
MMB Scripting Unleashed by
Bokzy, 2003
:: All rights reserved ::
http://www.bokzy.com
|